package main

import "fmt"

// 加法类
type Add struct {
	Object
}

func (a *Add) GetResult() int { // 方法的实现要和接口中方法的声明保持一致
	return a.numA + a.numB
}

// 减法类
type Sub struct {
	Object
}

func (s *Sub) GetResult() int {
	return s.numA - s.numB
}

type Object struct {
	numA int
	numB int
}
type Resulter interface {
	GetResult() int
}

func main() {
	add := Add{Object{10, 20}}
	num := add.GetResult()
	fmt.Println(num)

	sub := Sub{Object{20, 10}}
	num1 := sub.GetResult()
	fmt.Println(num1)
}
